package com.example.shop.service.impl;

import com.example.shop.entity.Address;
import com.example.shop.dao.AddressMapper;
import com.example.shop.service.AddressService;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;

/**
 * (Address)表服务实现类
 *
 * @author makejava
 * @since 2025-03-26 09:24:09
 */
@Service("addressService")
public class AddressServiceImpl implements AddressService {
    @Resource
    private AddressMapper addressMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param addressid 主键
     * @return 实例对象
     */
    @Override
    public Address queryById(Integer addressid) {
        return this.addressMapper.queryById(addressid);
    }


    /**
     * 新增数据
     *
     * @param address 实例对象
     * @return 实例对象
     */
    @Override
    public Address insert(Address address) {
        this.addressMapper.insert(address);
        return address;
    }

    /**
     * 修改数据
     *
     * @param address 实例对象
     * @return 实例对象
     */
    @Override
    public Address update(Address address) {
        this.addressMapper.update(address);
        return this.queryById(address.getAddressid());
    }

    /**
     * 通过主键删除数据
     *
     * @param addressid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer addressid) {
        return this.addressMapper.deleteById(addressid) > 0;
    }
}
